package com.zh.kotlin_mvvm.adapter

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zh.common.view.BadgeView
import com.zh.kotlin_mvvm.R
import com.zh.kotlin_mvvm.bean.ListBean

/**
 * @auth xiaohua
 * @time 2020/10/10 - 14:51
 * @desc DataBinding 与 recyclerView适配器 绑定的示例
 */
class ListAdapter : BaseQuickAdapter<ListBean, BaseViewHolder>(R.layout.item_list) {

    override fun convert(holder: BaseViewHolder, item: ListBean) {
        holder.setText(R.id.tvTitle, item.title)
        holder.getView<BadgeView>(R.id.badv).setShowNum(holder.layoutPosition % 2 == 0)
        holder.getView<BadgeView>(R.id.badv).setNumber(holder.layoutPosition + 5)
    }
}